<!DOCTYPE html>
<!-- saved from url=(0042)https://v3.bootcss.com/examples/dashboard/ -->
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="https://v3.bootcss.com/favicon.ico">

    <title>Dashboard</title>
    <!-- Bootstrap core CSS -->
    <link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <!-- Custom styles for this template -->
    <link href="/static/dashboard.css" rel="stylesheet">
    <link rel="stylesheet" href="/static/fontawesome/css/font-awesome.min.css">
</head>

<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
    <div class="container-fluid">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
                    aria-expanded="false" aria-controls="navbar">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand">SNKRS</a>
        </div>
        {% comment %} <div id="navbar" class="navbar-collapse collapse">
            <ul class="nav navbar-nav navbar-right">
                <li><a href="https://v3.bootcss.com/examples/dashboard/#">Dashboard</a></li>
                <li><a href="https://v3.bootcss.com/examples/dashboard/#">Settings</a></li>
                <li><a href="https://v3.bootcss.com/examples/dashboard/#">Profile</a></li>
                <li><a href="https://v3.bootcss.com/examples/dashboard/#">Help</a></li>
            </ul>
            <form class="navbar-form navbar-right">
                <input type="text" class="form-control" placeholder="Search...">
            </form>
        </div> {% endcomment %}
    </div>
</nav>

<div class="container-fluid">
    <div class="row">
        <div class="col-sm-3 col-md-2 sidebar">
            <ul class="nav nav-sidebar">
                <li class="active"><a href="/account_list/">账号列表页</a></li>
                {% comment %} <li><a href="/book_list/">XX列表</a></li>
                <li><a href="/author_list/">XX列表</a></li> {% endcomment %}
            </ul>

        </div>
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
            <h1 class="page-header">账号管理页面</h1>

            <div class="panel panel-primary">
                <!-- Default panel contents -->
                <div class="panel-heading">账号列表 <i class="fa fa-thumb-tack pull-right"></i></div>
                <div class="panel-body">
                    <div class="row" style="margin-bottom: 15px">
                        <div class="col-md-3">
                            <div class="input-group">
                                <input type="text" class="form-control" placeholder="请输入手机号码">
                                <span class="input-group-btn">
                                    <button class="btn btn-default" type="button">搜索</button>
                                </span>
                            </div><!-- /input-group -->
                        </div><!-- /.col-md-4 -->
                        <div class="col-md-9 pull-right">
                            <button class="btn btn-success" data-toggle="modal" data-target="#myModal">新增账号</button>
                        </div>

                    </div><!-- /.row -->

                    <table class="table table-bordered">
                        <thead>
                        <tr>
                            <th>#</th>
                            <th>手机号码</th>
                            <th>密码</th>
                        </tr>
                        </thead>
                        <tbody>
                        {% for account in account_list %}
                            <tr>
                                <td>{{ forloop.counter }}</td>
                                <td>{{ account.phone }}</td>
                                <td>{{ account.password }}</td>
                                <td>
                                    <a class="btn btn-danger" href="/delete_account/?id={{ account.phone }}">删除</a>
                                    {% comment %} <a class="btn btn-info" href="/edit_account/?id={{ account.id }}">编辑</a> {% endcomment %}
                                </td>
                            </tr>
                        {% endfor %}
                        </tbody>
                    </table>

                    <nav aria-label="Page navigation" class="text-right">
                        <ul class="pagination">
                            <li>
                                <a href="#" aria-label="Previous">
                                    <span aria-hidden="true">&laquo;</span>
                                </a>
                            </li>
                            <li><a href="#">1</a></li>
                            <li><a href="#">2</a></li>
                            <li><a href="#">3</a></li>
                            <li><a href="#">4</a></li>
                            <li><a href="#">5</a></li>
                            <li>
                                <a href="#" aria-label="Next">
                                    <span aria-hidden="true">&raquo;</span>
                                </a>
                            </li>
                        </ul>
                    </nav>
                </div>

            </div>
        </div>
    </div>
</div>


<div class="modal fade" tabindex="-1" role="dialog" id="myModal">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">用户信息</h4>
            </div>
            <form class="form-horizontal">
                {% comment %} {% csrf_token %} {% endcomment %}
                {% if message %}
                <div class="alert alert-warning">{{ message }}</div>
                {% endif %}
                <div class="modal-body">
                <div class="form-group">
                    <label for="phone" class="col-sm-2 control-label">手机号</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" id="phone" placeholder="Phone">
                    </div>
                </div>
                <div class="form-group">
                    <label for="password" class="col-sm-2 control-label">密码</label>
                    <div class="col-sm-10">
                        <input type="password" class="form-control" id="password" placeholder="Password">
                    </div>
                    </div>
                </div>
                <span id="error" style="color: red"></span>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal" id="exit">取消</button>
                    <button type="button" class="btn btn-primary" id="save">保存</button>
                </div>
            </form>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="/static/jquery-3.3.1.js"></script>
<script src="/static/bootstrap/js/bootstrap.min.js"></script>
<script>
    $("#save").click(function(){
        $("#error").text("")
        $("#save").attr('disabled',true);
        $.ajax({
            url:"/account_list/", 
            type:"post",
            data:{
                "phone": $("#phone").val(),
                "password":$("#password").val(),
                "csrfmiddlewaretoken":$('[name="csrfmiddlewaretoken"]').val()
            },
            success:function(data){
                $("#save").attr('disabled',false);
                var dataObj=JSON.parse(data);
                if(dataObj["msg"] == "success"){
                    $("#exit").click()
                }
                else{
                    $("#error").text(dataObj["msg"])
                }
            } 
        })
    })
</script>

</body>
</html>
